<template>
  <div class="box">
    <div class="sc-title">
      <h4 align="center">{{ title }}</h4>
    </div>
    <div class="sc-content">
      <router-view></router-view>
    </div>
    <div class="sc-menu">
      <div class="sc-menu-item">
        <span @click="changeList">商品列表</span>
      </div>
      <div class="sc-menu-item">
        <span @click="changeCart">购物车</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
let title = ref('商品列表')
const changeList = () => {
  router.push('/sc/list')
  title.value = '商品列表'
}
const changeCart = () => {
  router.push('/sc/cart')
  title.value = '购物车'
}
</script>

<style lang="scss" scoped>
.box {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 99vh;
}
.sc-title {
  width: 100%;
  height: 40px;
}
.sc-menu {
  width: 100%;
  height: 40px;
  display: flex;
}
.sc-content {
  flex: 1;
  width: 100%;
}
.sc-menu-item {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  border-right: 1px solid gray;
}
</style>
